#pragma once
#include <iostream>
#include <cstdio>
#include <cstdarg>
#include <ctime>
 
#define DEBUG  0
#define NORMAL 1
#define WARING 2
#define ERROR  3
#define FATAL  4
 
static const char* g_levelMap[5] = 
{
    "DEBUG",
    "NORMAL",
    "WARING",
    "ERROR",
    "FATAL"
};
 
static void logMessage(int level, const char *format, ...)
{
    // 1. 输出常规部分
    time_t timeStamp = time(nullptr);
    struct tm *localTime = localtime(&timeStamp);
    printf("[%s]  %d-%d-%d, %02d:%02d:%02d\n", g_levelMap[level], localTime->tm_year, localTime->tm_mon, \
                localTime->tm_mday, localTime->tm_hour, localTime->tm_min, localTime->tm_sec);
    
    // 2. 输出用户自定义部分
    va_list args;
    va_start(args, format);
    vprintf(format, args);
    va_end(args);
}